package com.zhangfb95.crosschain.infra.exception;

import com.zhangfb95.crosschain.infra.statuscode.StatusCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 框架级错误异常
 *
 * @author zhangfubing
 * @since 2020/2/20
 */
@Accessors(chain = true)
@Getter
@Setter
public class BusinessException extends RuntimeException {

    private String code = StatusCode.COMMON_ERROR.getCode();
    private Object data;

    public BusinessException() {
        super(null, null);
    }

    public BusinessException(String message) {
        super(message, null);
    }

    public BusinessException(String code, String message) {
        super(message, null);
        this.code = code;
    }

    public BusinessException(String code, String message, Object data) {
        super(message, null);
        this.code = code;
        this.data = data;
    }

    public BusinessException(String message, Exception exception) {
        super(message, exception);
    }

    public BusinessException(String message, Object data, Exception exception) {
        super(message, exception);
        this.data = data;
    }

    public BusinessException(Exception exception) {
        super(exception);
    }
}
